//
//  MKMyViewTabCellButton.swift
//  MOKOAnnounce
//
//  Created by 曹相召 on 2017/7/10.
//  Copyright © 2017年 cc.moko. All rights reserved.
//

import UIKit

class MKMyViewTabCellButton: UIButton {

    var number:UILabel!
    var tip:UILabel!
    var icon:UIImageView!
    
    override init(frame: CGRect) {
        super.init(frame: frame)
        self.number = UILabel.label(fontSize: 14, textColor: UIColorFromRGB(rgbValue: 0x333333, A: 1))
        self.number.textAlignment = .center
        self.addSubview(self.number)
        
        self.tip = UILabel.label(fontSize: 12, textColor: UIColorFromRGB(rgbValue: 0x333333, A: 1))
        self.tip.textAlignment = .center
        self.addSubview(self.tip)
        
    }
    
    func config(tip:String,num:Int) -> Void {
        self.tip.text = tip
        self.number.text = String.init(stringInterpolationSegment: num)
        self.setNeedsLayout()
    }
    
    override func layoutSubviews() {
        super.layoutSubviews()
        self.number.sizeToFit()
        self.tip.sizeToFit()
        
        self.number.frame = CGRect.init(x: 0, y: (self.height - self.number.height - self.tip.height) * 0.5, width: self.width, height: self.number.height)
        self.tip.frame = CGRect.init(x: 0, y: self.number.bottom + 5, width: self.width, height: self.tip.height)
    }
    required init?(coder aDecoder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
}
